package com.teach.food.commons;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import com.teach.dto.LoginUser;
import com.teach.entity.Shops;

import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class GetShopsInfo {
	@Autowired
	private  MongoTemplate template;
	
	public  Long getShopId(LoginUser user) {
		List<Shops> list = template.findAll(Shops.class);
		Long id =null;
		for (Shops shops : list) {
            if (shops.getUserName().equals(user.getUserName())) {
				id=shops.getId();
				log.debug("{},{}","666666666666666"+id,shops.getUserName());
				break;
			}
        }
		return id;
	}
	
	public  String getShopName(LoginUser user) {
		List<Shops> list = template.findAll(Shops.class);
		log.debug("{},{}","666666666666666",user.getUserName());
		String shopName =null;
		for (Shops shops : list) {
            if (shops.getUserName().equals(user.getUserName())) {
            	log.debug("{},{}","666666666666666"+shops.getShopName());
				shopName = shops.getShopName();
				break;
			}
        }
		return shopName;
	}
}
